﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _4_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void txt_RAM_TextChanged(object sender, EventArgs e)
        {

        }

        private void txt_RAM_Leave(object sender, EventArgs e)
        {
            try
            {
                int ram = int.Parse(txt_RAM.Text); // 尝试转换为数字
            }
            catch
            {
                MessageBox.Show("输入有误！内存请输入数字", "错误提示");
                txt_RAM.Text = ""; // 清空错误输入
                txt_RAM.Focus(); // 聚焦回内存文本框
            }
        }

        private void txt_List_Click(object sender, EventArgs e)
        {

        }

        private void btn_Confirm_Click(object sender, EventArgs e)
        {
            string brand = comboBox_Brand.Text;
            string type = rb_Laptop.Checked ? "笔记本" : rb_Desktop.Checked ? "台式机" : "平板电脑";
            string ram = txt_RAM.Text + "G";
            string cpu = rb_CPU1.Checked ? "酷睿" : rb_CPU2.Checked ? "奔腾" : "AMD";
            string peripheral = "";
            if (cb_HD.Checked) peripheral += "移动硬盘 ";
            if (cb_DVD.Checked) peripheral += "外置DVD光驱 ";
            if (cb_Mouse.Checked) peripheral += "无线键鼠套装";

            // 显示到配置清单文本框
            txt_List.Text = $"品牌：{brand}\n种类：{type}\n内存：{ram}\nCPU：{cpu}\n外设：{peripheral}";
        }
    }
}
